package Tools;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;

public class RandomSmartGridFileGenerator {
	
	public static void main(String[] args)
	{
		int numPlants = 10;
		Random rand = new Random();
		Map<String, String> allPlants = new HashMap<String, String>();
		Set<String> usedPlants = new HashSet<String>();
		for(int i = 0; i < numPlants; i++)
		{
			String plant = "Plant"+i+";";
			int type = Math.abs(rand.nextInt()%4);
			String type1 = "";
			if(type == 0)
			{
				type1 = "gas";
			}
			else if(type == 1)
				type1 = "coal";
			else if(type == 2)
				type1 = "wind";
			else if(type == 3)
				type1 = "solar";
			allPlants.put(plant, type1);
		}
		int numLines = rand.nextInt(numPlants*numPlants);
		Object[] plantNames = allPlants.keySet().toArray();
		for(int i = 0; i < numLines; i++)
		{
			int id = rand.nextInt(numPlants);
			String name = (String)plantNames[id];
			double connected = rand.nextDouble();
			if(connected >= 0.5)
			{
				int id2 = rand.nextInt(numPlants);
				if(id2 == id) continue;
				String name2 = (String)plantNames[id2];
				if(usedPlants.contains(name+name2) || usedPlants.contains(name2+name))
					continue;
				float distance = rand.nextInt(20);
				System.out.println(name+allPlants.get(name)+";"+name2+allPlants.get(name2)+";"+distance);
				usedPlants.add(name+name2);
				usedPlants.add(name2+name);
			}
			else
			{
				if(usedPlants.contains(name))
					continue;
				System.out.println(name+allPlants.get(name));
				usedPlants.add(name);
			}
		}
	}

}
